import React, { useEffect, useState } from "react";
import { Table, Button } from "antd";
import request from "../../utils/restRequest";

export default () => {
  const [val, setVal] = useState(1);
  const [data, setData] = useState([]);
  const columns = [
    { title: "姓名", dataIndex: "name", key: "name" },
    { title: "性别", dataIndex: "sex", key: "sex" },
    { title: "出生日期", dataIndex: "date", key: "date" },
    { title: "年龄", dataIndex: "age", key: "age" },
  ];

  useEffect(() => {
    request("/api/test", { method: "POST" }).then((res) => {
      console.log(res);

      setData(res.payload.content);
    });
  }, []);
  return (
    <>
      <div>
        测试{val} <Button onClick={() => setVal((pre) => pre + 1)}>点击</Button>
      </div>
      <Table columns={columns} dataSource={data} pagination={null} />
    </>
  );
};
